<template>
  <div class="agent-statistics">
    <h1>数据分析</h1>
    
    <div class="date-filter">
      <div class="filter-buttons">
        <button class="filter-btn active">今日</button>
        <button class="filter-btn">本周</button>
        <button class="filter-btn">本月</button>
        <button class="filter-btn">本季度</button>
        <button class="filter-btn">本年</button>
      </div>
      <div class="custom-date">
        <input type="date" class="date-input">
        <span class="date-separator">至</span>
        <input type="date" class="date-input">
        <button class="apply-btn">应用</button>
      </div>
    </div>
    
    <div class="statistics-cards">
      <div class="stat-card">
        <div class="stat-title">订单总量</div>
        <div class="stat-value">1,286</div>
        <div class="stat-change up">
          <i class="fas fa-arrow-up"></i> 12.5%
        </div>
        <div class="stat-chart">
          <!-- 这里将放置订单趋势小图表 -->
          <div class="chart-placeholder"></div>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-title">销售总额</div>
        <div class="stat-value">¥128,650.00</div>
        <div class="stat-change up">
          <i class="fas fa-arrow-up"></i> 8.2%
        </div>
        <div class="stat-chart">
          <!-- 这里将放置销售额趋势小图表 -->
          <div class="chart-placeholder"></div>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-title">新增分销商</div>
        <div class="stat-value">32</div>
        <div class="stat-change up">
          <i class="fas fa-arrow-up"></i> 15.8%
        </div>
        <div class="stat-chart">
          <!-- 这里将放置分销商增长小图表 -->
          <div class="chart-placeholder"></div>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-title">佣金总额</div>
        <div class="stat-value">¥12,865.00</div>
        <div class="stat-change down">
          <i class="fas fa-arrow-down"></i> 2.3%
        </div>
        <div class="stat-chart">
          <!-- 这里将放置佣金趋势小图表 -->
          <div class="chart-placeholder"></div>
        </div>
      </div>
    </div>
    
    <div class="chart-row">
      <div class="chart-card large">
        <div class="chart-header">
          <h3>销售趋势</h3>
          <div class="chart-actions">
            <button class="chart-action-btn">
              <i class="fas fa-download"></i>
            </button>
            <button class="chart-action-btn">
              <i class="fas fa-expand"></i>
            </button>
          </div>
        </div>
        <div class="chart-content">
          <!-- 这里将放置销售趋势图表 -->
          <div class="chart-placeholder">销售趋势图表将显示在这里</div>
        </div>
      </div>
    </div>
    
    <div class="chart-row">
      <div class="chart-card">
        <div class="chart-header">
          <h3>热销产品排行</h3>
          <div class="chart-actions">
            <button class="chart-action-btn">
              <i class="fas fa-download"></i>
            </button>
          </div>
        </div>
        <div class="chart-content">
          <!-- 这里将放置热销产品图表 -->
          <div class="chart-placeholder">热销产品图表将显示在这里</div>
        </div>
      </div>
      
      <div class="chart-card">
        <div class="chart-header">
          <h3>分销商业绩排行</h3>
          <div class="chart-actions">
            <button class="chart-action-btn">
              <i class="fas fa-download"></i>
            </button>
          </div>
        </div>
        <div class="chart-content">
          <!-- 这里将放置分销商业绩图表 -->
          <div class="chart-placeholder">分销商业绩图表将显示在这里</div>
        </div>
      </div>
    </div>
    
    <div class="chart-row">
      <div class="chart-card">
        <div class="chart-header">
          <h3>地区销售分布</h3>
          <div class="chart-actions">
            <button class="chart-action-btn">
              <i class="fas fa-download"></i>
            </button>
          </div>
        </div>
        <div class="chart-content">
          <!-- 这里将放置地区销售分布图表 -->
          <div class="chart-placeholder">地区销售分布图表将显示在这里</div>
        </div>
      </div>
      
      <div class="chart-card">
        <div class="chart-header">
          <h3>订单转化率分析</h3>
          <div class="chart-actions">
            <button class="chart-action-btn">
              <i class="fas fa-download"></i>
            </button>
          </div>
        </div>
        <div class="chart-content">
          <!-- 这里将放置订单转化率图表 -->
          <div class="chart-placeholder">订单转化率图表将显示在这里</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
// 数据分析页面组件逻辑
</script>

<style scoped>
.agent-statistics {
  padding: 20px;
}

.date-filter {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  align-items: center;
}

.filter-buttons {
  display: flex;
  gap: 10px;
}

.filter-btn {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #4b5563;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.filter-btn.active {
  background-color: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.custom-date {
  display: flex;
  align-items: center;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  width: 130px;
}

.date-separator {
  margin: 0 10px;
  color: #6b7280;
}

.apply-btn {
  padding: 8px 16px;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 10px;
}

.statistics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.stat-card {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: relative;
}

.stat-title {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 10px;
}

.stat-change {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-change.up {
  color: #10b981;
}

.stat-change.down {
  color: #ef4444;
}

.stat-chart {
  height: 50px;
}

.chart-placeholder {
  width: 100%;
  height: 100%;
  background-color: #f9fafb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-style: italic;
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.chart-card {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chart-card.large {
  grid-column: 1 / -1;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.chart-header h3 {
  margin: 0;
  font-size: 18px;
  color: #374151;
}

.chart-actions {
  display: flex;
  gap: 10px;
}

.chart-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s;
}

.chart-action-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.chart-content {
  height: 300px;
}

@media (max-width: 768px) {
  .date-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  
  .filter-buttons {
    overflow-x: auto;
    padding-bottom: 5px;
  }
  
  .custom-date {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .chart-row {
    grid-template-columns: 1fr;
  }
}
</style> 